﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Vortex.Drawing {

	//Contains methods for misc drawing stuff
	public sealed partial class Canvas2D {

		#region Buffer Drawing

		/// <summary>
		/// Draws the prepared vertex buffer. With the specified texture and color tint.
		/// </summary>
		/// <param name="buffer">The buffer to draw.</param>
		public void DrawBuffer(VertexBuffer buffer) {
			DrawBuffer(buffer, null, ColorU.Blank);
		}

		/// <summary>
		/// Draws the prepared vertex buffer. With the specified texture and color tint.
		/// </summary>
		/// <param name="buffer">The buffer to draw.</param>
		/// <param name="colorTint">The color tint to apply.</param>
		public void DrawBuffer(VertexBuffer buffer, ColorU colorTint) {
			DrawBuffer(buffer, null, colorTint);
		}

		/// <summary>
		/// Draws the prepared vertex buffer. With the specified texture and color tint.
		/// </summary>
		/// <param name="buffer">The buffer to draw.</param>
		/// <param name="texture">The primary texture to use. May be <c>null</c>, that means texture should be blank.</param>
		/// <param name="colorTint">The color tint to apply.</param>
		public void DrawBuffer(VertexBuffer buffer, BaseTexture texture, ColorU colorTint) {
			if (null == buffer) throw new ArgumentNullException("buffer");

			if (buffer.VertexCount > 0) {
				//need to activate canvas context
				_renderer.SetCanvas(this, texture);
	
				//and then draw vertex buffer through the renderer
				_renderer.DrawVertexBuffer(buffer, _transform, colorTint);
			}
		}

		#endregion
	}
}
